import { observable, action } from "mobx"
import { Item } from "antd-mobile/lib/tab-bar";
import { runInAction } from 'mobx'
class Song {
    constructor(rootStore) {
        this.rootStore = rootStore
        console.log( this.rootStore)
    }
    @observable list=[]
    //说明 : 调用此接口 , 可获取视频排行榜 
    
    @action.bound get_personalized() {
        fetch(`http://106.12.79.128:666/personalized?limit=6`)
        .then(body => body.json())
        .then(data => {
            this.set_personalized(data.result)
            // console.log(data.result)
        })
    }
    @action.bound set_personalized(list){
        try{
            this.list = [...list]
        }catch{
            // console.log('error')
        }
       
    }

   //  //获取歌单的数据
    @observable list_Song=[]
    //说明 : 调用此接口 , 可获取视频排行榜 
    
    @action.bound get_list_Song(value){
        fetch(`http://106.12.79.128:666/playlist/detail?id=${value}`)
        .then(body => body.json() )
        .then(data => {
            const that = this
            runInAction(function () {
                that.list_Song=data.playlist
            })
            
        })
    }
}
export default  Song